package ui;

import bot.ScriptMethods;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextArea;

public class NpcUI extends JPanel {

	private ScriptMethods sM;
	private JFrame frame1;

	public NpcUI() {
		this.sM = new ScriptMethods();
		initComponents();
		frame1.setVisible(true);
	}

	private void initComponents() {
		frame1 = new JFrame();
		JButton closeButton = new JButton();

		frame1.setTitle("ARS");
		Container container = frame1.getContentPane();
		container.setLayout(null);
		container.setPreferredSize(new Dimension(240, 290));

		closeButton.setBounds(new Rectangle(new Point(4, 270), new Dimension(60, 23)));
		closeButton.setText("Close");
		closeButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				frame1.dispose();
			}
		});
		container.add(closeButton);

		JTextArea npcs = new JTextArea();

		try { for (int size = 0; size < sM.getNpcCount(); size++) {
			String id = Integer.toString(sM.getNpcID(size));
			String name = sM.getNpcName(sM.getNpcID(size));
			npcs.append(name + ": " + id + "\n");
		} } catch (Exception e) { }

		npcs.setEditable(false);

		JScrollPane npcScroll = new JScrollPane(npcs);
		npcScroll.setBounds(new Rectangle(new Point(4, 4), new Dimension(241, 260)));
		container.add(npcScroll);

		frame1.pack();
		frame1.setResizable(false);
		frame1.setLocationRelativeTo(null);
	}

}